
***ROPER DATA POLL NEEDS TO BE DOWNLOADED AS STATA FILE
*https://ropercenter.cornell.edu/ipoll/study/31117209

use "$data/Roperpoll_data.dta", clear


decode cstate , gen(state_name)


statastates, name(state_name  )
keep if _merge==3
drop _merge 

rename state_abbrev code

merge m:1 intvwdat using "$data/MAPPER.dta"
keep if _merge==3
drop _merge

merge m:1 code year month day using "$data/COVID.STATES.DAILY.dta"
keep if _merge==3
drop _merge



foreach var in  Q16A Q16B Q16C {

replace `var' = . if `var'>4

local lab: variable label `var'

gen concerned`var' = `var'<=2 if `var'!=. 

label variable concerned`var' "Concerned `lab'"


}


replace Q14 = . if Q14>4

foreach var in Q14 Q16A Q16B Q16C {

local lab: variable label `var'

gen swap`var' = 4-`var'

su swap`var'

gen sdswap`var' = (swap`var'-r(mean))/`r(sd)'
}




gen anycovid_confirmed = covid_confirmed >0 if covid_confirmed !=.

encode code, gen(cc)

egen reg = group(sregion usr)



su covid_confirmed
gen sd_covid_confirmed = covid_confirmed/`r(sd)'

gen Q15dummy = Q15==1 if Q15<=2
gen Q17Bdummy = Q17B==1 if Q17B<=2


label variable anycovid_confirmed "Any Covid-19 case"




foreach var in anycovid_confirmed  { 
estimates clear



eststo: reghdfe   sdswapQ16A `var'    , absorb( PARTY5   age genderva educ income date) vce(cl cc) old
estadd ysumm

eststo: reghdfe   sdswapQ16B `var'    , absorb( PARTY5   age genderva educ income date) vce(cl cc) old
estadd ysumm

eststo:  reghdfe   sdswapQ16C `var'    , absorb( PARTY5   age genderva educ income date) vce(cl cc) old
estadd ysumm


estadd local empt =  " "

esttab using "$tables/table-roper-poll-`var'.tex", keep(`var' )   replace  nolines nomtitles fragment nowrap  label nodepvars   stats(empt ymean r2 N_clust1 N , labels( " " "Mean of DV" "R$^2$" "States" "Observations" ) fmt(%9.3g)) starlevels(* 0.10 ** 0.05 *** 0.01) collabels(none) style(tex) cells(b(star fmt(%9.3f)) se(par))  nonumbers

}






